`timescale 1ns/1ns

module tb_MSG_PADDING ;

reg clock;
reg rst_n;
reg [31:0] msg;
reg msg_valid;
reg is_last_word;
reg [1:0] is_last_word_byte;
wire [511:0] msg_padding;
wire a_block_ready;
wire all_block_finished;

initial begin
    clock = 1'b0;
    forever begin
        #5 clock = ~clock;
    end
end

initial begin
    rst_n = 1'b0;
    #25 rst_n = 1'b1;
end

//test1--------------------------------------------------------
//initial begin
//    msg = 0;
//    msg_valid = 0;
//    is_last_word = 0;
//    is_last_word_byte = 0;
//    #25
//    @(negedge clock) begin
//        msg = 32'h61626300;
//        msg_valid = 1;
//        is_last_word = 1;
//        is_last_word_byte = 2'b10;
//    end
//    @(negedge clock) begin
//        msg = 0;
//        msg_valid = 0;
//        is_last_word = 0;
//        is_last_word_byte = 0;
//    end
//    wait(all_block_finished)
//    #100
//    $finish;
//end

//test2-----------------------------------------
//initial begin
//    msg = 0;
//    msg_valid = 0;
//    is_last_word = 0;
//    is_last_word_byte = 0;
//    #25
//    repeat(15) begin
//        @(negedge clock) begin
//        msg = 32'h61626364;
//        msg_valid = 1;
//       end
//    end
//    @(negedge clock) begin
//        msg = 32'h61626364;
//        msg_valid = 1;
//        is_last_word = 1;
//        is_last_word_byte = 2'b11;
//    end
//    @(negedge clock) begin
//        msg = 0;
//        msg_valid = 0;
//        is_last_word = 0;
//        is_last_word_byte = 0;
//    end
//    wait(all_block_finished)
//    #500
//    $finish;
//end

//test3-------------------------------------
initial begin
    msg = 0;
    msg_valid = 0;
    is_last_word = 0;
    is_last_word_byte = 0;
    #25
    repeat(15) begin
        @(negedge clock) begin
        msg = 32'h61626364;
        msg_valid = 1;
       end
    end
    @(negedge clock) begin
        msg = 32'h61626364;
        msg_valid = 1;
        is_last_word = 0;
        is_last_word_byte = 2'b00;
    end
    @(negedge clock) begin
        msg = 0;
        msg_valid = 0;
        is_last_word = 0;
        is_last_word_byte = 0;
    end
    repeat(15) begin
        @(negedge clock) begin
        msg = 32'h61626364;
        msg_valid = 1;
       end
    end
    @(negedge clock) begin
        msg = 32'h61626364;
        msg_valid = 1;
        is_last_word = 1;
        is_last_word_byte = 2'b11;
    end
    @(negedge clock) begin
        msg = 0;
        msg_valid = 0;
        is_last_word = 0;
        is_last_word_byte = 0;
    end
    wait(all_block_finished)
    #500
    $finish;
end

always @(posedge clock) begin
    if(a_block_ready) begin
        $display("INFO : A BLOCK IS PADDED READY !");
        $display("       MSG_PAD_BLOCK = %h",msg_padding);
    end
        
end

MSG_PADDING PAD0(
    .clk_i(clock),
    .rst_n_i(rst_n),

    .msg_i(msg),
    .msg_valid_i(msg_valid),
    .is_last_word_i(is_last_word),
    .is_last_word_byte_i(is_last_word_byte),

    .msg_padding_o(msg_padding),
    .a_block_ready(a_block_ready),
    .all_block_finished(all_block_finished)
);


endmodule //tb_MSG_PADDING
